import random

import numpy as np
import matplotlib.pyplot as plt

# arr1 = np.array([1,2,3])
# # print(type(arr1))
#
# # print(arr1.ndim)
# print(arr1.shape)

# arr2 = np.ones(shape=(2,3),dtype=np.int8)
# # print(arr2)
#
# arr3 = np.zeros(shape=(3,1),dtype=np.uint8)
# print(arr3)

# arr =np.full(shape=(3,3,3),fill_value=6)
# print(arr)

# arr2 = np.eye(N=3,M=3,k=1)
# print(arr2)

# arr =  np.linspace(0,100,10,endpoint=False)
# print(arr)

# arr =  np.arange(0,100,step=6)
# print(arr)

# arr = np.random.randint(low=0,high=100,size=(10,))
# print(arr)

# arr = np.random.randn(1000)
# # print(arr)
# plt.hist(arr)
# plt.show()
# arr = np.random.normal(loc=175,scale=10,size=10)
# print(arr)

# arr = np.random.random(size=(10, 1))
# print(arr)

# arr = np.random.permutation(10)
# print(arr)

# np.random.seed(1)
# arr =  np.random.randint(0, 10, size= 5)
# print(arr)

# arr = np.random.randint(-5,5,size=(3,4))
# print(arr)
# arr = np.linspace(0,15,num=5,endpoint=False)
# print(arr)

# arr = np.arange(0,15,step=3)
# print(arr)

# arr = np.random.random(size=(100,100,3))
# print(arr)

# arr = np.linspace(0,2*np.pi,num=8,endpoint=False)
# print(arr)
# arr5 = np.random.randint(0,10,size=(3,4))
# print(arr5)
# # print(arr5[2][1])
# print(arr5[2,1])

# arr1 = np.random.randint(0,100,size=10)
# print(arr1)
# # index = [1, 2,1, 2,1, 2]
# # print(arr1[index])
#
# index2 = np.random.permutation(10)
# print(arr1[index2])

# arr2 = np.random.randint(0,100,size=(5,5))
# print(arr2)
# print(arr2[[0,1]])
# print(arr2[:,[0,1]])

# arr1 = np.random.randint(0,100,size=10)
# print(arr1)
# print(arr1[0:3])
# print(arr1[-4:])
# print(arr1[2:5])
# print(arr1[0:-1:2])
# print(arr1[::-1])

# arr2 = np.random.randint(0,100,size=(5,5))
# print(arr2)
# print(arr2[:,[1,2]])

# arr3 = np.random.randint(0,100,size=(5,))
# boolIndex = [False,True,False,False,True]
# print(arr3)
# print(arr3[boolIndex])



# data2 =np.random.randint(0,100,size=(5,4))
# print(data2)
# print(data2[:,[2,3]])
# print(data2[:,[-2,-1]])
# print(data2[:,-2:])

# print(data2[:,[False,False,True,True]])
# print(data2[[0,1,2,3,4],-2:])

# a1 = np.random.randint(0, 10, size=(3, 4))
# a2 = np.random.randint(10, 20, size=(3, 4))
# # print(a1)
# # # print(a2)
# a3 = np.random.randint(10,20,size=(3,3))
# # print(a3)
# # data = np.concatenate((a1, a3), axis=1)
# # print(data)
# print(a1)
# print(a2)
#
# print(np.vstack((a1,a2)))
# print(np.hstack((a1,a3)))


# arr = np.random.randint(0, 100, size=(6, 5))
# a1,a2,a3= np.split(arr, indices_or_sections=[2,3], axis=1)
# print(arr)
# print(a1)
# print(a2)
# print(a3)

# a1 = np.random.randint(0, 10, size=(4,4))
# a2 = np.random.randint(0, 10, size=(8,4))
#
# arr = np.concatenate((a1, a2), axis=0)
# print(arr)

# a1 = np.random.randint(0, 10, size=5)
# print(a1.dtype)
#
# a2 = a1.astype(np.float32)
# print(a2.dtype)

#18 运算
# a1 = np.random.random(size=(3,3))
# a2 = np.random.randint(0,10,size=(3,3))
#
# print(a1+a2)
# print(a2 > 2)

# a = np.ones((4,3,2))
# b = np.random.randint(0,10,size=(3,2))
#
#
# print(a,b)
# print(a+b)

# a = np.arange(3).reshape((3,1))
# b = np.arange(3)
#
# print(a+b)


# a = np.ones((4,1))
# b = np.arange(4)
# print(a)
# print(b)
# print(a + b)

# data = np.random.randint(7, 10, size=100)
# print(data <8)

#21 聚合操作
# data = np.random.randint(0, 10, size=(3,2))
# print(data)
# print(data.sum(axis=1))


# data = np.random.randint(0, 10, size=10)
# data = data.astype(np.float32)
#
# data[1] = np.nan
# print(data)
# print(data.sum())
#
# print(np.nansum(data))
# print(np.nanmax(data))

# data = np.random.randint(0, 2, size=10).astype(np.bool_)
# print(data)
# print(data.any())
# print(data.all())
#
# data1 = np.array([True,True,True])
# print(data1.all())

# score = np.random.randint(0,100,size=10)
# print(score)
# print((score > 60).any())


# score = np.random.randint(0, 100, size=100)
# data1 = (score > 60)*1
# print(data1.mean())

# def standerd_transform(x):
#     return (x-x.mean())/x.std()
#
# score = np.random.randint(0, 100, size=100)
# print(standerd_transform(score))

# data = np.random.randn(100)
# print((data >data.mean()*3).any())

# data = np.random.randn(1000, 3)
#
# temp = data > data.std(axis=0)*3
# print(temp)
# print(temp.any(axis=0))

# a = np.ones(shape=(4,4))
# b = np.ones(shape=(4,4))
#
# print((a == b).all())

# data = [1,2,3,4]
# # data.append(5)
# # print(data)
#
# arr = np.array(data)
# arr = np.append(arr,8)
# print(arr)

# arr2 =  np.random.randint(0, 10, size=(4,3))
# print(arr2)
# arr2 = np.append(arr2,[[1,2,3]],axis=0)
# print(arr2)

# data = np.ones(shape=(4,1))
# kk =np.append(arr2,data,axis=1)
# print(kk)
# data = [1,2,3,4,5]
# arr = np.array(data)
#
# arr = np.insert(arr,2,100)
# print(arr)

# arr2 = np.random.randint(0, 10, size=(4,3))
# arrr = np.insert(arr2,2,[[1,1,2,3]],axis=1)
# print(arr2)
# print(arrr)
# ar = np.delete(arrr,2,axis=0)
# print(ar)

# arr = np.random.randint(0, 10, size=8)
# arr2 = arr.reshape((4,2))
# print(arr2)
# arr2 = np.random.randint(0, 10, size=(4,3))
# print(arr2)

# for i in arr2.flat:
#     print(i)

# print(arr2.flatten())
# print(arr2.ravel())
# print(arr2.transpose())
# print(arr2.transpose([1,0]))
# print(np.sin(np.pi/2))
# data = np.random.random(size=10)*2*np.pi -np.pi
# print(data)
# print(np.sin(data))

# data2 = np.random.random(size=10)
# print(data2)
# print(np.around(data2,3))
# print(np.add(data2,1))

# a = np.random.randint(0,10,size=(5,3))
# b = np.random.randint(0,100,size=10)
# print(np.add(a,b))
# print(b)
# print(np.power(b,2))
# print(np.power(b,1/2))
# print(np.mod(b,7))
# print(np.e)
# print(np.log10(10000))
# print(b)
# print(np.argmax(b))
# print(np.where(b < 60))
# print(np.sort(b))
# print(np.argsort(b))


data = np.random.permutation(10000)
print(data)
print(np.partition(data,-2)[-2:])
print(np.partition(data,2)[:2])